import re

from DataValidator import DataValidator

class UrlTypeValidator(DataValidator):

	def validate(self, url):
		rv = True
		try:
			fileName = url[url.rindex("/"):]
			# TODO: add supported extensions to geocrawler.conf
			if fileName.find(".") != -1 and re.match("(\w|\W)+(.htm|.HTM|.asp|.ASP|.jsp|.JSP|.php|.PHP)", fileName) == None:
				rv = False
		except ValueError:
			rv = False
		except AttributeError:
			rv = False
		return rv 
